<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="t_product" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 检测项目 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序编号" prop="">
              {{t_product.process_num}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序条形码" prop="">
              {{t_product.process_barcode}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序类别" prop="">
              {{t_product.description}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序名称" prop="">
              {{t_product.process_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序描述" prop="">
              {{t_product.process_des}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序时长" prop="">
              {{t_product.process_duration}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="改变状态为" prop="status_id">
              <el-select style='width:100%' v-model="t_product.status_id">
                <el-option label="已完成" value="2" />
                <el-option label="已跳过" value="1" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item>
              <el-button @click="addRecordProcessSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 工序明细 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序编号" prop="">
              {{t_product.process_num}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序条形码" prop="">
              {{t_product.process_barcode}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序类别" prop="">
              {{t_product.description}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序名称" prop="">
              {{t_product.process_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序描述" prop="">
              {{t_product.process_des}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工序时长" prop="">
              {{t_product.process_duration}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 国家标准 </span>
      </div>
      <el-table :data="s_file">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="gotoPage('/xcapi/ProcessFile/DownloadFile.do?&fileverid='+scope.row.version_id+''+vueparams+'')">下载</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="主题" prop="subject">
        </el-table-column>
        <el-table-column label="文件" prop="version_id">
          <template slot-scope="scope">
          </template>
        </el-table-column>
        <el-table-column label="类型" prop="client_filename">
        </el-table-column>
        <el-table-column label="尺寸" prop="size">
        </el-table-column>
        <el-table-column label="版本" prop="version">
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 记录模板 </span>
      </div>
      <el-table :data="s_table">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="模板名称" prop="name">
        </el-table-column>
        <el-table-column label="操作" prop="">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/produce/flow/RecordTemplate?CMIDrecord_table_id='+scope.row.record_table_id+'&cpopup=reload'+vueparams+'')" type='primary'>查看模板</el-link>
          </template>
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'AddRecordProcess',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        t_product: {
          process_num: null,
          process_barcode: null,
          description: null,
          process_name: null,
          process_des: null,
          process_duration: null,
          status_id: null,
          process_num: null,
          process_barcode: null,
          description: null,
          process_name: null,
          process_des: null,
          process_duration: null,
        },
        s_file: [],
        step: [],
        s_table: [],
        action_step_work: {
          action_step_work: null,
        },
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/addRecordProcess?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      addRecordProcessSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/addRecordProcessSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
